//ST*****************************************加载等待组件*********************************************
function JyyLoading() {
}
JyyLoading.start = function(options) {
	var ctrl = document.getElementById("jyyLoading");
	if(ctrl){
		return;
	}
	
	var defaults = {
        opacity: 1,//loading页面透明度
        backgroundColor: "rgba(148, 148, 148, 0.3)",//loading页面背景色
        borderColor: "#bbb",//提示边框颜色
        borderWidth: 1,//提示边框宽度
        borderStyle: "solid",//提示边框样式
        loadingTips: "正在处理数据，请稍候...",//提示文本
        TipsColor: "#666",//提示颜色
        delayTime: 1000,//页面加载完成后，加载页面渐出速度
        zindex: 999,//loading页面层次
        sleep: 0//设置挂起,等于0时则无需挂起
    }
	var options = $.extend(defaults, options);

    //获取页面宽高
    var _PageHeight = document.documentElement.clientHeight;
    var _PageWidth = document.documentElement.clientWidth;

    //在页面未加载完毕之前显示的loading Html自定义内容
    var _LoadingHtml = '<div id="jyyLoading" style="position:fixed;left:0;top:0;_position: absolute;width:100%;height:' + _PageHeight + 'px;background:' + options.backgroundColor + ';opacity:' + options.opacity + ';filter:alpha(opacity=' + options.opacity * 100 + ');z-index:' + options.zindex + ';"><div id="jyyLoadingTips" style="position: absolute; cursor1: wait; width: auto;border-color:' + options.borderColor + ';border-style:' + options.borderStyle + ';border-width:' + options.borderWidth + 'px; height:60px; line-height:60px; padding-left:45px; padding-right: 5px;border-radius:10px;  background: #ffffff url(../images/loading.gif) no-repeat 10px center; color:' + options.TipsColor + ';font-size:16px;">' + options.loadingTips + '</div></div>';

    //呈现loading效果
    $("body").append(_LoadingHtml);

    //获取loading提示框宽高
    var _LoadingTipsH = document.getElementById("jyyLoadingTips").clientHeight;
    var _LoadingTipsW = document.getElementById("jyyLoadingTips").clientWidth;

    //计算距离，让loading提示框保持在屏幕上下左右居中
    var _LoadingTop = _PageHeight > _LoadingTipsH ? (_PageHeight - _LoadingTipsH) / 2 : 0;
    var _LoadingLeft = _PageWidth > _LoadingTipsW ? (_PageWidth - _LoadingTipsW) / 2 : 0;

    $("#jyyLoadingTips").css({
        "left": _LoadingLeft + "px",
        "top": _LoadingTop + "px"
    });

    //监听页面加载状态
    /*document.onreadystatechange = function(){
	    if (document.readyState == "complete") {
            var loadingMask = $('#jyyLoading');

            setTimeout(function() {
                loadingMask.animate({
                    "opacity": 0
                },
                options.delayTime,
                function () {
                    $(this).hide();
                });
            },
            options.sleep);
        }
	};*/
}
JyyLoading.end = function() {
	$("#jyyLoading").remove();
}
//ED*****************************************加载等待组件*********************************************

//ST*****************************************区块加载等待组件*********************************************
function JyyModelLoading() {
}
JyyModelLoading.start = function(id) {
	var ctrl = document.getElementById(id+"Loading");
	if(ctrl){
		return;
	}
	var defaults = {
        opacity: 1,//loading页面透明度
        backgroundColor: "rgba(148, 148, 148, 0.3)",//loading页面背景色 195,190,190
        borderColor: "#bbb",//提示边框颜色
        borderWidth: 1,//提示边框宽度
        borderStyle: "solid",//提示边框样式
        loadingTips: "正在加载数据，请稍候...",//提示文本
        TipsColor: "#666",//提示颜色
        delayTime: 1000,//页面加载完成后，加载页面渐出速度
        zindex: 999,//loading页面层次
        sleep: 0,//设置挂起,等于0时则无需挂起
		marginTop:0,
		marginLeft:0
    }
    //获取DIV宽高
    var _PageHeight = $("#"+id).height();
    var _PageWidth = $("#"+id).width();
	
    //在页面未加载完毕之前显示的loading Html自定义内容
    var _LoadingHtml = '<div id="'+id+'Loading" style="position:absolute;left:0;top:0;margin-top:' +defaults.marginTop+ 'px;margin-left:' + defaults.marginLeft + 'px;width:' + _PageWidth + 'px;height:' + _PageHeight + 'px;background:' + defaults.backgroundColor + ';opacity:' + defaults.opacity + ';filter:alpha(opacity=' + defaults.opacity * 100 + ');z-index:' + defaults.zindex + ';"><div id="'+id+'LoadingTips" style="position: absolute; cursor1: wait; width: auto;border-color:' + defaults.borderColor + ';border-style:' + defaults.borderStyle + ';border-width:' + defaults.borderWidth + 'px; height:60px; line-height:60px; padding-left:45px; padding-right: 5px;border-radius:10px;  background: #ffffff url(../images/loading.gif) no-repeat 10px center; color:' + defaults.TipsColor + ';font-size:16px;">' + defaults.loadingTips + '</div></div>';
	
	$("#"+id).append(_LoadingHtml);
	
    //获取loading提示框宽高
    var _LoadingTipsH = $("#"+id+"LoadingTips").height();
    var _LoadingTipsW = $("#"+id+"LoadingTips").width();

    //计算距离，让loading提示框保持在屏幕上下左右居中
    var _LoadingTop = _PageHeight > _LoadingTipsH ? (_PageHeight - _LoadingTipsH) / 2 : 0;
    var _LoadingLeft = _PageWidth > _LoadingTipsW ? (_PageWidth - _LoadingTipsW) / 2 : 0;

    $("#"+id+"LoadingTips").css({
        "left": _LoadingLeft + "px",
        "top": _LoadingTop + "px"
    });
}
JyyModelLoading.end = function(id) {
	$("#"+id+"Loading").remove();
}

//ED*****************************************区块加载等待组件*********************************************
